<?php

namespace App\Params\Backend;

use App\Params\Param;
/**
 * 日志列表查询参数
 *
 * @author: WangBin
 * @date: 2022/01/13
 * @mail: <849850352@qq.com>
 */
class LogListParam extends Param
{
    public $title = '';
    public $time_range = [];
    public $api_url = '';
    public $page_size = 20;
    public $page = 1;
    public $status = '';

    public function rules()
    {
        return [
            'title' => 'nullable|string',
            'page_size' => 'nullable|integer',
            'page' => 'nullable|integer',
            'time_range' => 'nullable|array',
            'status' => 'nullable|string',
            'api_url' => 'nullable|string'
        ];
    }

    /**
     * @return string
     */
    public function getTitle(): string
    {
        return $this->title;
    }

    /**
     * @param string $title
     */
    public function setTitle(string $title): void
    {
        $this->title = $title;
    }

    /**
     * @return array
     */
    public function getTimeRange(): array
    {
        return $this->time_range;
    }

    /**
     * @param array $time_range
     */
    public function setTimeRange(array $time_range): void
    {
        $this->time_range = $time_range;
    }

    /**
     * @return string
     */
    public function getApiUrl(): string
    {
        return $this->api_url;
    }

    /**
     * @param string $api_url
     */
    public function setApiUrl(string $api_url): void
    {
        $this->api_url = $api_url;
    }

    /**
     * @return int
     */
    public function getPageSize(): int
    {
        return $this->page_size;
    }

    /**
     * @param int $page_size
     */
    public function setPageSize(int $page_size): void
    {
        $this->page_size = $page_size;
    }

    /**
     * @return int
     */
    public function getPage(): int
    {
        return $this->page > 0 ? --$this->page : 0;
    }

    /**
     * @param int $page
     */
    public function setPage(int $page): void
    {
        $this->page = $page;
    }

    /**
     * @return string
     */
    public function getStatus(): string
    {
        return $this->status;
    }

    /**
     * @param string $status
     */
    public function setStatus(string $status): void
    {
        $this->status = $status;
    }
}
